python programming

[tool.poetry]
name = "my-package"
version = "0.1.0"
description = "The description of the package"

license = "MIT"

authors = [
    "Sébastien Eustace <sebastien@eustace.io>"
]

readme = 'README.md'  # Markdown files are supported

repository = "https://github.com/sdispater/poetry"
homepage = "https://github.com/sdispater/poetry"

keywords = ['packaging', 'poetry']

[tool.poetry.dependencies]
python = "~2.7 || ^3.2"  # Compatible python versions must be declared here
toml = "^0.9"
# Dependencies with extras
requests = { version = "^2.13", extras = [ "security" ] }
# Python specific dependencies with prereleases allowed
pathlib2 = { version = "^2.2", python = "~2.7", allows-prereleases = true }
# Git dependencies
cleo = { git = "https://github.com/sdispater/cleo.git", branch = "master" }

# Optional dependencies (extras)
pendulum = { version = "^1.4", optional = true }

[tool.poetry.dev-dependencies]
pytest = "^3.0"
pytest-cov = "^2.4"

[tool.poetry.scripts]
my-script = 'my_package:main'

Instead put all your package executables under package_name/scripts/ (i.e., inside the package, and no just inside the repo) and have a section like the following in pyproject.toml. These executables should have a main() function which will serve as the entrypoint:

[tool.poetry.scripts]
name_of_tool = "package_name.scripts.name_of_tool:main"
# more tools can be added here...

The following is NOT recommended.

# Potential scripts.py contents - have `poetry` behave like `yarn`
#
# This is a temporary workaround till Poetry supports scripts, see
# https://github.com/sdispater/poetry/issues/241.
from subprocess import check_call


def format() -> None:
    check_call(
        ["black", "--check", "--diff", "src/", "tests/"],
    )


def reformat() -> None:
    check_call(["black", "src/", "tests/"])


def lint() -> None:
    check_call(["flake8", "src/", "tests/"])
    check_call(["mypy", "src/backend/", "tests/"])


def start() -> None:
    check_call(["python", "src/backend/run.py"])


def test() -> None:
    check_call(["pytest", "tests/"])